package com.cw.DesignModel23.Ceational.BuilderPattern.builder5;

/**
 * 拓展一
 * 【要求】
 *
 * 请修改 Builder类TetBuilder类和HTMLBuilder类，确保“在调用makeString 方法、makeItems 方法和close方法之前必须且只能调用一次makeTitle方法”
 */
public abstract class Builder2 {
    private boolean initialized = false;
    public void makeTitle(String title) {
        if (!initialized) {
            buildTitle(title);
            initialized = true;
        }
    }
    public void makeString(String str) {
        if (initialized) {
            buildString(str);
        }
    }
    public void makeItems(String[] items) {
        if (initialized) {
            buildItems(items);
        }
    }
    public void close() {
        if (initialized) {
            buildDone();
        }
    }
    protected abstract void buildTitle(String title);
    protected abstract void buildString(String str);
    protected abstract void buildItems(String[] items);
    protected abstract void buildDone();
}

